package com.hooper.iot.face.components;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ Copyright
 * @ Author     ：wangcheng.
 * @ Date       ：Created in 17:07 2022/5/25
 * @ Description：
 * @ Modified By：
 * @Version: $
 */
@Component
public class DeviceInfoRespository {
    private final static Map<String, JSONObject> DEVICEINFO_MAP = new ConcurrentHashMap<>();

    public void put(String key, JSONObject value) {
        DEVICEINFO_MAP.put(key, value);
    }

    public JSONObject get(String key) {
        synchronized (this) {
            return DEVICEINFO_MAP.get(key);
        }
    }

    public void remove(String key) {
        synchronized (this) {
            DEVICEINFO_MAP.remove(key);
        }
    }

    public int size() {
        return DEVICEINFO_MAP.size();
    }

    public Map getMap() {
        return DEVICEINFO_MAP;
    }
}
